package ArrayList;

import java.util.ArrayList;

public class Demo1 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList</*JDK7要在此处加String*/>();
       /* System.out.println(list);*///[]
        list.add("aaa");
        System.out.println(list);//[aaa]
        list.add("bbb");
        System.out.println(list);//[aaa,bbb];
        list.add("ccc");
        System.out.println(list);//[aaa,bbb,ccc];
        list.remove("aaa");//删除了aaa
        System.out.println(list);//[bbb,ccc]
        String str = list.remove(0);//相当于数组的索引
        System.out.println(str);//bbb
        System.out.println(list);//[ccc];
        String result = list.set(0,"ddd");//把第0个元素替换为ddd
        System.out.println(result);//ddd;
        System.out.println(list);//[ddd]
        String s = list.get(0);//查询第几号元素
        System.out.println(s);//ddd
    }
}
